<?php
class TeacherController {
	public function getTeacherTime(){
		$date = Common::getPostOrGet('date');
		$time = HttpServerManager::getTeacherServer()->userGetTeacherTime($_POST['teacherId'],$date);
		exit ($time);
	}
	public function info(){
		$teacherId = Common::getGetStrValue('id');
		if(!Common::is_number($teacherId)){
			header('location:teacher.html');
			exit;
		}
		$data = HttpDaoManager::getTeacherDao()->get($teacherId);
		$public = HttpServerManager::getIndexIncludeServer()->getPublic('teacher.htm');
		$data['good_course'] = str_replace('|','',$data['good_course']);
		$data['good_course'] = explode(',',$data['good_course']);
		$course_types = Common::_t('course_type');
		$tmp = array();
		foreach ($data['good_course'] as $v){
			$tmp[]=  $course_types[$v];
		}
		$data['good_course'] = implode(',',$tmp);
		$data['level'] = Common::_t('english_level');
		$data['top'] = $public['top'];
		$data['left'] = $public['left'];
		$data['foot'] = $public['foot'];
		$data['time'] = Common::getTimes();
		$page= getParamValue('page');
		$data['date'] = HttpServerManager::getTeacherStartCourseServer()->weeksTimeStamps($page,0);
		$data['courseTime'] = HttpServerManager::getTeacherStartCourseServer()->getCourseTimeByDataStatus($data['date'],$teacherId,1);

		$today_start_book_time = Common::getDefaultNextOpenTimeByHalf();
		$today_date_time = strtotime(date('Y-m-d'));
		$startClassTime = array();
		foreach ($data['time'] as $v){
			foreach ($data['date'] as $v1){
				if (isset($data['courseTime'][$v1][$v['time']]['class_time_flg'])){
					$startClassTime[$v['time']][$v1]['class_time_flg']=1;
					$startClassTime[$v['time']][$v1]['id']=$data['courseTime'][$v1][$v['time']]['id'];
					$startClassTime[$v['time']][$v1]['open_date']=$data['courseTime'][$v1][$v['time']]['open_date'];
					$startClassTime[$v['time']][$v1]['open_time']=$data['courseTime'][$v1][$v['time']]['open_time'];
					$startClassTime[$v['time']][$v1]['teacher_id']=$data['courseTime'][$v1][$v['time']]['teacher_id'];
					if($data['courseTime'][$v1][$v['time']]['open_date']==$today_date_time){
						if($data['courseTime'][$v1][$v['time']]['open_time']<$today_start_book_time){
							unset($startClassTime[$v['time']]);
						}
					}
				}
			}
		}
		$data['english_week'] = Common::_t('week');
		$data['startClassTime'] = $startClassTime;
		//Common::escapeArray($data);
		return $data;
	}
}
?>